﻿
app.controller('TaskController', function ($scope, $http, $window, $compile, $filter, ipCookie, common, option, Upload) {
    $scope.result = {};
    $scope.dateOption = option.date;
    $scope.datetimeOption = option.datetime;

    $scope.GoHiddenTroublePage = function (Id, status) {
        if (status == 4) {
            location.href = "../Hiddentrouble/MHiddenTroubleReview?FormId=" + Id + "&backurl=../Task/MHiddenTroubleTask";
        }
        else if (status == 2) {
            location.href = "HiddenTrouble/MHiddenTroubleSolutionList?FormId=" + Id;
        }
        else if (status == 1) {
            location.href = "../HiddenTrouble/MHiddenTroubleSolutionAdd?FormId=" + Id + "&backurl=../Task/MHiddenTroubleTask";
        }
        else {
            location.href = "../HiddenTrouble/MHiddenTroubleRectification";
        }
    }

    $scope.MGetDailyCheckTaskList = function () {
        $scope.DailyCheckTaskList = [];
        $http({
            method: 'POST',
            url: '../Task/MGetIncompleteDailyCheckTaskByType',
        })
            .success(function (ret) {
                common.success($scope, null, ret);
                if (ret.Code == 100) {
                    $scope.DailyCheckTaskList = ret.Data;
                   
                }
                else {
                    mui.toast(ret.Msg);
                }
            })
            .error(function (data, status, headers, config) {
                alertify.alert("请检查网络");
            });
    }

    $scope.GetHiddenTroubleTaskList = function () {
        $scope.HiddenTroubleTaskList = [];
        $http({
            method: 'POST',
            url: '../Task/GetHiddenTroubleTaskList',
        })
            .success(function (ret) {
                common.success($scope, null, ret);
                if (ret.Code == 100) {
                    $scope.HiddenTroubleTaskList = ret.Data;

                }
                else {
                    mui.toast(ret.Msg);
                }
            })
            .error(function (data, status, headers, config) {
                alertify.alert("请检查网络");
            });
    }

    $scope.GetTaskCount = function () {
        $http({
            method: 'POST',
            url: '../Task/GetMyTaskCount'
        })
            .success(function (ret) {
                common.success($scope, null, ret);
                $scope.DataLoading = false;
                if (ret.Code == 100) {
                    $scope.TaskCount = ret.Data;
                }
                else {
                    mui.toast(ret.Msg);
                }
            })
            .error(function (data, status, headers, config) {
                alertify.alert("请检查网络");
            });
    }

    $scope.GetMyCheckTaskCount = function () {
        $http({
            method: 'POST',
            url: '../Task/GetMyCheckTaskCount'
        })
            .success(function (ret) {
                common.success($scope, null, ret);
                $scope.DataLoading = false;
                if (ret.Code == 100) {
                    $scope.CheckTaskCount = ret.Data;
                }
                else {
                    mui.toast(ret.Msg);
                }
            })
            .error(function (data, status, headers, config) {
                alertify.alert("请检查网络");
            });
    }

    $scope.GetHiddenTroubleTaskCount = function () {
        $http({
            method: 'POST',
            url: '../Task/GetHiddenTroubleTaskCount'
        })
            .success(function (ret) {
                common.success($scope, null, ret);
                $scope.DataLoading = false;
                if (ret.Code == 100) {
                    $scope.HiddenTroubleTaskCount = ret.Data;
                }
                else {
                    mui.toast(ret.Msg);
                }
            })
            .error(function (data, status, headers, config) {
                alertify.alert("请检查网络");
            });
    }

    $scope.GetSepcialCheckTask = function () {
        mui.showLoading("正在加载..", "div");
        $scope.SepcialCheckTaskList = [];
        $http({
            method: 'POST',
            url: '../Task/GetSepcialCheckTask'
        })
            .success(function (ret) {
                mui.hideLoading();
                common.success($scope, null, ret);
                $scope.DataLoading = false;
                if (ret.Code == 100) {
                    $scope.SepcialCheckTaskList = ret.Data;
                }
                else {
                    alertify.alert(ret.Msg);
                }
            })
            .error(function (data, status, headers, config) {
                mui.hideLoading();
                alertify.alert("请检查网络");
               
            });
    }

    $scope.GetIssueReportTaskList = function () {
        $scope.IssueTaskList = [];
        $http({
            method: 'POST',
            url: '../Task/GetIssueReportTaskList'
        })
            .success(function (ret) {
                common.success($scope, null, ret);
                $scope.DataLoading = false;
                if (ret.Code == 100) {
                    $scope.IssueTaskList = ret.Data;
                }
                else {
                    mui.toast(ret.Msg);
                }
            })
            .error(function (data, status, headers, config) {
                mui.toast("请检查网络");
            });
    }

    $scope.GetDeviceTask = function () {
        $scope.DeviceTask = [];
        $http({
            method: 'POST',
            url: '../Task/GetDeviceTask'
        })
            .success(function (ret) {
                common.success($scope, null, ret);
                $scope.DataLoading = false;
                if (ret.Code == 100) {
                    $scope.DeviceTask = ret.Data;
                }
                else {
                    mui.toast(ret.Msg);
                }
            })
            .error(function (data, status, headers, config) {
                alertify.alert("请检查网络");
            });
    }


});
